using System;

namespace Evaluant.NLinq.Expressions
{
	public class MemberExpression : Expression
	{
        public MemberExpression(Expression statement)
        {
            Statement = statement;
        }

        public MemberExpression(Expression statement, Expression previous)
        {
            Statement = statement;
            Previous = previous;
        }

        public Expression Previous { get; set; }
        public Expression Statement { get; set; }

        public override string ToString()
        {
            string result = String.Empty;

            if (Previous != null)
            {
                result += Previous.ToString() + ".";
            }

            result += Statement.ToString();

            return result;
        }

        public override void Accept(NLinqVisitor visitor)
        {
            visitor.Visit(this);
        }

        public override ExpressionTypes ExpressionType
        {
            get { return ExpressionTypes.MemberAccess; }
        }
    }
}
